package bdz.projects.cbt.utils
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.utils.Dictionary;
	
	import gs.*;
	import gs.easing.*;
	public class CBTButtonRolls extends EventDispatcher{
		private static var instance:CBTButtonRolls;
		private static var colorDict:Dictionary;
		public function CBTButtonRolls(se:SingletonEnforcer){
			super();
		}
		public static function getInstance():CBTButtonRolls{
			if(instance == null){
				instance = new CBTButtonRolls(new SingletonEnforcer());
				colorDict = new Dictionary();
			}
			return instance;
		}
		public function registerButton(targ:DisplayObject, clr:Number):void{
			colorDict[targ] = clr;
			try{
				(targ as SimpleButton).doubleClickEnabled = true;
			}catch(e:Error){
				(targ as MovieClip).doubleClickEnabled = true;
			}
			
			targ.addEventListener(MouseEvent.ROLL_OVER, onButtonRolls);
			targ.addEventListener(MouseEvent.ROLL_OUT, onButtonRolls);
		}
		private function onButtonRolls(evt:MouseEvent):void{
			if(evt.target.alpha != 1){
				return;
			}
			if(evt.type == MouseEvent.ROLL_OVER){
				TweenMax.to(evt.target, 1, {glowFilter:{color:colorDict[evt.target], strength:1, quality:3, alpha:1, blurX:30, blurY:30, inner:true },ease:Strong.easeOut});
			}else{
				TweenMax.to(evt.target, 1, {glowFilter:{color:colorDict[evt.target], strength:1, quality:3, alpha:0, blurX:0, blurY:0, inner:true }, ease:Strong.easeInOut});
			}
		}
		
		
	}
}
internal class SingletonEnforcer {}